//
//  PubTableViewCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/15.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "PubTableViewCell.h"

#define W self.contentView.frame.size.width/375
#define H self.contentView.frame.size.height/150

@implementation PubTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];
    }
    return self;
}

- (void)createView {
    [super createView];
    self.leftImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.leftImageView];
    
    self.upLeftLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15];
    self.upLeftLabel.numberOfLines = 0;
    
    self.upRightLabel.font = [UIFont systemFontOfSize:10];
    self.upRightLabel.textAlignment = NSTextAlignmentRight;
    
    self.mistLabel.font = [UIFont systemFontOfSize:12];
    
    self.downLeftLabel.font = [UIFont systemFontOfSize:12];
    self.downLeftLabel.textColor = [UIColor orangeColor];

    self.downRightLabel.font = [UIFont systemFontOfSize:14];
    self.downRightLabel.textColor = [UIColor redColor];
    self.downRightLabel.textAlignment = NSTextAlignmentRight;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.leftImageView.frame = CGRectMake(W * 5, H * 5, 120 * W, 140 * H);
    self.upLeftLabel.frame = CGRectMake(130 * W, H * 5, 170 * W, 70 * H);
    self.upRightLabel.frame = CGRectMake(305 * W, H * 2, 65 * W, H * 30);
    self.mistLabel.frame = CGRectMake(130 * W, H * 75, 240 * W, 30 * H);
    self.downLeftLabel.frame = CGRectMake(130 * W, H * 115, 70 * W, 30 * H);
    self.downRightLabel.frame = CGRectMake(280 * W, H * 100, 85 * W, 40 * H);

}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.upLeftLabel.textColor = [UIColor whiteColor];
        self.upRightLabel.textColor = [UIColor whiteColor];
        self.mistLabel.textColor = [UIColor whiteColor];
        self.downLeftLabel.textColor = [UIColor whiteColor];
        self.downRightLabel.textColor = [UIColor whiteColor];
    }
    else {
        self.upLeftLabel.textColor = [UIColor blackColor];
        self.upRightLabel.textColor = [UIColor blackColor];
        self.mistLabel.textColor = [UIColor blackColor];
        self.downLeftLabel.textColor = [UIColor orangeColor];
        self.downRightLabel.textColor = [UIColor redColor];
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}








@end
